﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria.GameContent.UI.Elements;

namespace Terraria.ModLoader.UI
{
	// Token: 0x02000283 RID: 643
	internal class UIHoverImage : UIImage
	{
		// Token: 0x06001A3F RID: 6719 RVA: 0x00012B4A File Offset: 0x00010D4A
		public UIHoverImage(Texture2D texture, string hoverText) : base(texture)
		{
			this.hoverText = hoverText;
		}

		// Token: 0x06001A40 RID: 6720 RVA: 0x0042858C File Offset: 0x0042678C
		protected override void DrawSelf(SpriteBatch spriteBatch)
		{
			base.DrawSelf(spriteBatch);
			if (base.IsMouseHovering)
			{
				float x = Main.fontMouseText.MeasureString(this.hoverText).X;
				Vector2 vector = new Vector2((float)Main.mouseX, (float)Main.mouseY) + new Vector2(16f);
				if (vector.Y > (float)(Main.screenHeight - 30))
				{
					vector.Y = (float)(Main.screenHeight - 30);
				}
				if (vector.X > this.Parent.GetDimensions().Width + this.Parent.GetDimensions().X - x - 16f)
				{
					vector.X = this.Parent.GetDimensions().Width + this.Parent.GetDimensions().X - x - 16f;
				}
				Utils.DrawBorderStringFourWay(spriteBatch, Main.fontMouseText, this.hoverText, vector.X, vector.Y, new Color((int)Main.mouseTextColor, (int)Main.mouseTextColor, (int)Main.mouseTextColor, (int)Main.mouseTextColor), Color.Black, Vector2.Zero, 1f);
			}
		}

		// Token: 0x04001780 RID: 6016
		internal string hoverText;
	}
}
